furny.ga
Class RoomVector

java.lang.Object
  extended by furny.ga.RoomVector

public final class RoomVector
extends java.lang.Object

The room vector is a tuple of x- and y-coordinates and rotation steps. It is part of the furniture genotype.

Since:
11.08.2012
Author:
Stephan Dreyer

Field Summary
private static int MAX_ROTATION
           
private static float ROTATION_DEGREES
           
private  int rotGene
           
private  int xGene
           
private  int yGene
           
 
Constructor Summary
RoomVector(int xGene, int yGene, int rotationSteps)
          Creates a new room vector and sets all fields.
 
Method Summary
protected  RoomVector clone()
           
 float diffAngleDeg(RoomVector vec)
          Calculates the degrees difference between the rotations.
 int diffRotation(RoomVector vec)
          Calculates the rotation steps difference between the rotations.
 float distance(RoomVector vec)
          Calculates the euklidean distance between this an the other room vector.
 boolean equals(java.lang.Object obj)
           
 RoomVector getRotatedInstance(int rotationSteps)
          Creates a new room vector that is rotated by the given number of 90° steps.
 float getRotation()
          Getter for the rotation.
 int getRotationSteps()
          Get the gene for the rotation.
 RoomVector getTranslatedInstance(int x, int y)
          Creates a new room vector that is translated by x and y.
 float getX()
          Get the real x coordinate.
 int getXGene()
          Get the gene for x.
 float getY()
          Get the real y coordinate.
 int getYGene()
          Get the gene for y.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROTATION_DEGREES

private static final float ROTATION_DEGREES
See Also:
Constant Field Values

MAX_ROTATION

private static final int MAX_ROTATION
See Also:
Constant Field Values

xGene

private final int xGene

yGene

private final int yGene

rotGene

private final int rotGene
Constructor Detail

RoomVector

public RoomVector(int xGene,
                  int yGene,
                  int rotationSteps)
Creates a new room vector and sets all fields.

Parameters:
xGene - The gene for x (in centimeters).
yGene - The gene for y (in centimeters).
rotationSteps - The number of the 90° rotations.
Since:
11.08.2012
Method Detail

getXGene

public int getXGene()
Get the gene for x.

Returns:
X gene (centimenters).
Since:
11.08.2012

getYGene

public int getYGene()
Get the gene for y.

Returns:
Y gene (centimenters).
Since:
11.08.2012

getX

public float getX()
Get the real x coordinate.

Returns:
X coordinate (meters).
Since:
11.08.2012

getY

public float getY()
Get the real y coordinate.

Returns:
Y coordinate (meters).
Since:
11.08.2012

getRotation

public float getRotation()
Getter for the rotation.

Returns:
The rotation in degrees.
Since:
11.08.2012

getRotationSteps

public int getRotationSteps()
Get the gene for the rotation.

Returns:
Rotation gene (90° rotations).
Since:
11.08.2012

getTranslatedInstance

public RoomVector getTranslatedInstance(int x,
                                        int y)
Creates a new room vector that is translated by x and y.

Parameters:
x - Translation x (centimeters).
y - Translation y (centimeters).
Returns:
The new room vector.
Since:
11.08.2012

getRotatedInstance

public RoomVector getRotatedInstance(int rotationSteps)
Creates a new room vector that is rotated by the given number of 90° steps.

Parameters:
rotationSteps - Steps to rotate.
Returns:
Rotated room vector.
Since:
11.08.2012

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clone

protected RoomVector clone()
Overrides:
clone in class java.lang.Object

distance

public float distance(RoomVector vec)
Calculates the euklidean distance between this an the other room vector.

Parameters:
vec - The other room vector.
Returns:
distance in centimenters.
Since:
11.08.2012

diffAngleDeg

public float diffAngleDeg(RoomVector vec)
Calculates the degrees difference between the rotations.

Parameters:
vec - The other room vector.
Returns:
The degrees between -180 and +180.
Since:
11.08.2012

diffRotation

public int diffRotation(RoomVector vec)
Calculates the rotation steps difference between the rotations.

Parameters:
vec - The other room vector.
Returns:
The difference between -2 and 2.
Since:
11.08.2012

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object